package org.eenie.kdassistant.utils.zzt_encode;

import java.security.MessageDigest;

/**
 * Created by Eenie on 2017/8/14.
 * Email: eeniework@gmail.com
 * Des:
 */

public class DataDigestUtil {
    public static final String UTF8 = "UTF-8";

    public static String digest(String paramString1, String paramString2, String paramString3) {
        try {
            paramString2 = encryptBASE64(encryptMD5((paramString1 + paramString2).getBytes(paramString3)));
            paramString1 = paramString2;
            if (System.getProperty("line.separator").equals("\n")) {
                paramString1 = paramString2.replaceAll("\\n", "\r\n");
            }
            return paramString1;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

    private static String encryptBASE64(byte[] paramArrayOfByte)
            throws Exception {
        return new HexUtil().b(paramArrayOfByte);
    }

    private static byte[] encryptMD5(byte[] paramArrayOfByte)
            throws Exception {
        MessageDigest localMessageDigest = MessageDigest.getInstance("MD5");
        localMessageDigest.update(paramArrayOfByte);
        return localMessageDigest.digest();
    }
}
